<?php

/**
 * <b>XUCBrowserUserAgent简介:</b>
 * <p>UserAgent的扩展类，提供设备更加丰富的信息</p>
 *
 * <b>功能描述:</b>
 * <p>1. 提供设备的分辨率信息，包括像素分辨率，逻辑分辨率，屏幕旋转特性</p>
 * <p>2. 提供更丰富的浏览器功能特性，例如浏览模式，夜间模式等</p>
 * <p>3. 可动态扩展，提供比User-Agent更加丰富的信息来满足不同场景下的用户体验</p>
 *
 * @author cairq@ucweb.com
 */
class XUCBrowserUserAgent extends UserAgent {
    private $xUCBrowserUserAgent          = null;
    private $pixel                        = null;
    private $density                      = null;
    private $proxyMode                    = null;
    private $browsingView                 = null;
    private $nightMode                    = null;
    private $noImageMode                  = null;
    private $screenRotation               = null;
    private $netType                      = null;
    private $btype                        = null;
    
    /**
     * 
     * <p>获取HTTP Header X-UCBrowser-UA数据</p>
     *
     * @return
     */
    public function getxUCBrowserUserAgent() {
        return $this->xUCBrowserUserAgent;
    }
    
    public function setxUCBrowserUserAgent($xUCBrowserUserAgent) {
        $this->xUCBrowserUserAgent = $xUCBrowserUserAgent;
    }

    /**
     * 
     * <p>获取手持设备像素分辨率，例如：320*240</p>
     *
     * @return
     */
    public function getPixel() {
        return $this->pixel;
    }
    public function setPixel($pixel) {
        $this->pixel = $pixel;
    }
    
    /**
     * 
     * <p>获取手持设备逻辑分辨率，例如：320*240， 此值只在iPhone，Android等智能设备上生效</p>
     *
     * @return
     */
    public function getDensity() {
        return $this->density;
    }
    public function setDensity($density) {
        $this->density = $density;
    }
    
    /**
     * 
     * <p>获取浏览器访问模式</p>
     *
     * @return
     */
    public function getProxyMode() {
        return $this->proxyMode;
    }
    public function setProxyMode($proxyMode) {
        $this->proxyMode = $proxyMode;
    }
    
    /**
     * 
     * <p>获取浏览器浏览模式</p>
     *
     * @return
     */
    public function getBrowsingView() {
        return $this->browsingView;
    }
    public function setBrowsingView($browsingView) {
        $this->browsingView = $browsingView;
    }
    
    /**
     * 
     * <p>获取浏览器夜间模式</p>
     *
     * @return
     */
    public function getNightMode() {
        return $this->nightMode;
    }
    public function setNightMode($nightMode) {
        $this->nightMode = $nightMode;
    }
    
    /**
     * 
     * <p>获取浏览器无图模式</p>
     *
     * @return
     */
    public function getNoImageMode() {
        return $this->noImageMode;
    }
    public function setNoImageMode($noImageMode) {
        $this->noImageMode = $noImageMode;
    }
    
    /**
     * 
     * <p>获取浏览器的屏幕旋转模式</p>
     *
     * @return
     */
    public function getScreenRotation() {
        return $this->screenRotation;
    }
    
    public function setScreenRotation($screenRotation) {
        $this->screenRotation = $screenRotation;
    }
    
    /**
     * 
     * <p>当前请求是否为无图模式</p>
     *
     * @return
     */
    public function isNoImageMode(){
        return isset($this->noImageMode) && $this->noImageMode == GlobalConstant::FUNCTION_OPEN;
    }
    
    /**
     * 
     * <p>当前请求模式是否为中转模式</p>
     *
     * @return
     */
    public function isProxyMode(){
        return isset($this->proxyMode) && $this->proxyMode == GlobalConstant::FUNCTION_OPEN;
    }
    
    /**
     * 
     * <p>是否为夜间模式</p>
     *
     * @return
     */
    public function isNightMode(){
        return isset($this->nightMode) && $this->nightMode == GlobalConstant::FUNCTION_OPEN;
    }
    
    /**
     * 
     * <p>浏览模式是否为适应屏幕</p>
     *
     * @return
     */
    public function browingViewIsAdaptScreen(){
        return isset($this->browsingView) && $this->browsingView == GlobalConstant::BROWSING_VIEW_ADATER_SCREEN;
    }
    
    /**
     * 
     * <p>浏览模式是否为缩放模式</p>
     *
     * @return
     */
    public function browingViewIsZoom(){
        return isset($this->browsingView) && $this->browsingView == GlobalConstant::BROWSING_VIEW_ZOOM;
    }
    
    /**
     * 
     * <p>屏幕旋转是否跟随系统</p>
     *
     * @return
     */
    public function screenRotationFollowSystem(){
        return isset($this->screenRotation) && $this->screenRotation == GlobalConstant::SCREEN_ROTATION_FOLLOW_SYSTEM;
    }
    
    /**
     * 
     * <p>屏幕旋转是否锁定竖屏</p>
     *
     * @return
     */
    public function screenRotationLockVertical (){
        return isset($this->screenRotation) && $this->screenRotation == GlobalConstant::SCREEN_ROTATION_LOCK_VERTICAL;
    }
    
    /**
     * 
     * <p>屏幕旋转是否锁定横屏</p>
     *
     * @return
     */
    public function screenRotationLockHorizontal(){
        return isset($this->screenRotation) && $this->screenRotation == GlobalConstant::SCREEN_ROTATION_LOCK_HARIZONTAL;
    }
    
    /**
     * <p>网络类型</p>
     * @return
     */
    public function getNetType() {
	return $this->netType;
    }

    public function setNetType($netType) {
	$this->netType = $netType;
    }

    /**
     * <p>渠道类型</p>
     * @return
     */
    public function getBtype() {
	return $this->btype;
    }

    public function setBtype($btype) {
    	$this->btype = $btype;
    }
        
    public function toString(){
        $sb  = parent::toString();
        $sb .= "isProxyMode:                      " . UserAgent::toBoolValue($this->isProxyMode()) . "\r\n";
        $sb .= "isNightMode:                     " . UserAgent::toBoolValue($this->isNightMode()) . "\r\n";
        $sb .= "isNoImageMode:                   " . UserAgent::toBoolValue($this->isNoImageMode()) . "\r\n";
        $sb .= "browingViewIsAdaptScreen:        " . UserAgent::toBoolValue($this->browingViewIsAdaptScreen()) . "\r\n";
        $sb .= "browingViewIsZoom:               " . UserAgent::toBoolValue($this->browingViewIsZoom()) . "\r\n";
        $sb .= "screenRotationFollowSystem:      " . UserAgent::toBoolValue($this->screenRotationFollowSystem()) . "\r\n";
        $sb .= "screenRotationLockVertical:      " . UserAgent::toBoolValue($this->screenRotationLockVertical()) . "\r\n";
        $sb .= "screenRotationLockHorizontal:    " . UserAgent::toBoolValue($this->screenRotationLockHorizontal()) . "\r\n";
        $sb .= "Pixel:                           " . $this->getPixel() . "\r\n";
        $sb .= "Density:                         " . $this->getDensity() . "\r\n";
        $sb .= "NetType:                         " . $this->getNetType() . "\r\n";
        $sb .= "Btype:                           " . $this->getBtype() . "\r\n";
        return $sb;
    }
}
?>
